
package com.zkmonitor.configuration;

import com.zkmonitor.interceptor.AuthorizationInterceptor;
import com.zkmonitor.interceptor.LoginRequiredInterceptor;
import com.zkmonitor.interceptor.NavInterceptor;
import com.zkmonitor.interceptor.PassportInterceptor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Registers all interceptors to {@link InterceptorRegistry}.
 *
 */
@Configuration
public class WebConfiguration extends WebMvcConfigurerAdapter {

    @Bean
    public NavInterceptor getNavInterceptor() {
        return new NavInterceptor();
    }

    @Bean
    public AuthorizationInterceptor getAuthorizationInterceptor() {
        return new AuthorizationInterceptor();
    }

    @Bean
    public PassportInterceptor getPassportInterceptor() {
        return new PassportInterceptor();
    }

    @Bean
    public LoginRequiredInterceptor getLoginRequiredInterceptor() {
        return new LoginRequiredInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getPassportInterceptor());
        registry.addInterceptor(getLoginRequiredInterceptor());
        registry.addInterceptor(getAuthorizationInterceptor());
        registry.addInterceptor(getNavInterceptor());
        super.addInterceptors(registry);
    }

}
